<?php
session_start();
require_once('_db/db.class.php');
require_once('utils.class.php');
require_once('config.php');
require_once('debug.class.php');
require_once('import.class.php');
header('Content-Type: text/html; charset='.Config::_CHARSET_);



	#doc
	#	classname:	Core
	#	scope:		PUBLIC
	#
	#/doc

	class Core extends DB {

		public static $_instance = NULL;

		public static function getInstance() {
			if (is_null(self::$_instance)) {
				$class = __CLASS__;
				self::$_instance = new $class();
			}
			return self::$_instance;
		}

		public static function Utils($method, $param) {
			if (debug::endebug()) {
				return debug::d(Utils::getInstance()->$method($param));
			} else {
				return Utils::getInstance()->$method($param);
			}
		}

		public static function init() {
			try {
				DB::getInstance()->connect(Config::$_config['datebase']['db_host'], Config::$_config['datebase']['db_user'], Config::$_config['datebase']['db_pass'], Config::$_config['datebase']['db_name'], Config::$_config['datebase']['db_locale']);
			} catch (Exception $e) {
				echo $e->getFile();
			}
		}

		public static function run() {
		  Config::init();
		  if (debug::endebug()) {
		    debug::message("Загрузка load.php..");
		  }
      try {
		    require_once('load.php');
		  } catch (Exception $e) {

		    print $e->getMessage();
		    print $e->getFile();
		    print $e->getLine();
		  }
		}

		public static function import($file) {

		  import::getInstance()->execute($file);
		}

		public static function importDB() {

		  require_once('_db/db.class.php');
		  require_once('_db/db.query.class.php');
		}

	}

?>

